package com.idempotent.demo.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.idempotent.demo.entity.Order;
import com.idempotent.demo.service.OrderService;

@RestController
@RequestMapping("/api/order")
public class OrderConreoller {

    @Autowired
    private OrderService orderService;

    @RequestMapping("/detail")
    public ResponseEntity detail(@RequestParam("orderId") String orderId) {

        Order byOrderNo = orderService.findByOrderNo(orderId);
        Map<String, Object> result = new HashMap<>();
        result.put("status", "UP");
        result.put("data", byOrderNo);
        result.put("message", "幂等性服务运行正常");
        return ResponseEntity.ok(result);

    }
}
